<?php
namespace app\common\model\finance;
use app\common\model\file\FileModel;
use app\common\model\file\MerchantFileModel;
use think\Model;

class MerchantWithdrawalModel extends Model
{
    // 表名
    protected $name = 'merchant_withdrawal';
    // 表主键
    protected $pk = 'id';
    // 关联图片
    public function image()
    {
        return $this->hasOne(MerchantFileModel::class, 'file_id', 'image_id')->append(['file_url'])->where(where_disdel());
    }
    /**
     * 获取图片链接
     * @Apidoc\Field("")
     * @Apidoc\AddField("image_url", type="string", desc="图片链接")
     */
    public function getImageUrlAttr($value, $data)
    {
        return $this['image']['file_url'] ?? '';
    }
}
